<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;
//use App\Model\ArticleCategories;

class Article extends Model
{
    //
    protected $table='articles';
    protected $dates=['deleted_at'];
    const UPDATED_AT = 'updated_at';
    const CREATED_AT = 'created_at';
    protected $primaryKey='article_id';
    public $timestamps=false;
    protected $dateFormat='Y-m-d H:i:s';
    protected  $fillable=[
        'article_category_id',
        'title',
        'serial_number',
        'introduction',
        'content',
        'cover_photo_id',
        'public_at',
        'created_at',
        'updated_at',
        'approved_at',
        'author_id',
        'created_by',
        'updated_by',
        'approved_by',
        'order',
        'is_comment_opened',
        'is_share_opened',
        'is_draft',
        'is_published',
        'is_visible_all',
        'is_published_notify',
        'is_approved',
        'comment_count'
    ];
    public function articleCategories(){
        return $this->belongsTo(ArticleCategories::class,'article_category_id','article_category_id');
    }

    //过滤查询列表
    public function scopeList($query,$cateId){
        $query->where('article_category_id',$cateId);
    }

}
